class code3 {
    public int minSubArrayLen(int target, int[] nums) {
        //1.left right
        //2.进窗口
        //3.判断
        //出窗口
        //更新结果
        int left=0,right=0;
        int ret = Integer.MAX_VALUE;
        int sum = 0;
        while(right<nums.length) {
            sum += nums[right];
            while(sum>=target) {
                ret = Math.min(ret,right-left+1);
                sum -= nums[left++];
            }
            right++;
        }
        return ret==Integer.MAX_VALUE?0:ret;
    }
}